#pragma once

#include "object.h"
#include "..\math\vector.h"
#include "..\common\def.h"

struct Bezier; 

class EE_EXPORT CCamera : public CObject
{
public:
	struct cameraData
	{
		float m_mouseSpeed; 
		float m_mouseAccelerate; 
		float m_walkSpeed; 
	}; 
	private:
cameraData m_Data; 

		float	m_yaw; 
		float	m_pitch; 
		float	m_mouseVelocity; 
		
		float	m_nearPlane; 
		float	m_farPlane; 
		float	m_fov; 

		Vector3f cameraForward; 

		//CObject	*m_pLookat; 

		Bezier *m_pPositionBezier; 
		Bezier *m_pDirectionBezier; 
		float m_BezierFrac; 

		const float	m_followDistance; 


		void (*pUpdateFunc) (Matrix4f*); 

		
		inline void UpdateFreeView(const float deltaTime); 
		inline void UpdateFollowBeizer(const float deltaTime); 

public:
	enum CameraState { FREEVIEW = 0, FOLLOW_BEIZER, STATIC} m_State; 
		CCamera(void); 
		~CCamera(void); 

		HRESULT initalizeCamera(const CCamera::cameraData& data); 
		HRESULT initalizeProjection(const float nearPlane, const float farPlane, const float fov); 
		
		HRESULT	releaseCamera(); 
		void	Update(const float deltaTime); 

		void setBeizerPaths(Bezier* pPositionPath,Bezier* pLookatPath); 

		inline static void ApplyFreeview(CCamera* pCamera, const Vector3f& deltaMove, const float deltaYaw, const float deltaPitch);
		
		void	setUpdateFunc(void (*pFunc) (Matrix4f*)); 
		void	setPosition(const Vector3f &); 
		void	setDirection(CObject *pEntity); 
		void	setState(CameraState state); 
		CameraState	getState(void); 

		float	getFarPlane(void); 
		float	getNearPlane(void); 

		Vector3f getDirection();
		Vector3f getPosition();
		void	setDirection(const Vector3f &direction); 
}; 
